package com.hz.score.ent.controller;

import com.hz.score.common.dto.PageDto;
import com.hz.score.ent.dto.EntBaseInfoDto;
import com.hz.score.ent.dto.EntCommInfoDto;
import com.hz.score.ent.service.EntService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "企业模块编辑类", description = "编辑企业基础数据和年度经营数据")
@Controller
@RequestMapping("/ent")
public class EntController {

    @Resource
    EntService entService;

    @ApiOperation("分页查询企业基础数据")
    @PostMapping("/base/page")
    @ResponseBody
    private PageDto<EntBaseInfoDto> pageBaseEnt(@RequestBody EntBaseInfoDto entBaseInfoDto,
                                                @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        return entService.pageBaseEnt(entBaseInfoDto, pageSize, pageNum);
    }

    @ApiOperation("新增企业经营数据")
    @PostMapping("/base/new")
    @ResponseBody
    private void newBaseEnt(@RequestBody EntBaseInfoDto entBaseInfoDto) {
        entService.newBaseEnt(entBaseInfoDto);
    }

    @ApiOperation("更新企业经营数据")
    @PostMapping("/base/update")
    @ResponseBody
    private void updateBaseEnt(@RequestBody EntBaseInfoDto entBaseInfoDto) {
        entService.newBaseEnt(entBaseInfoDto);
    }

    @ApiOperation("删除企业经营数据")
    @PostMapping("/base/delete")
    @ResponseBody
    private void delBaseEnt(@RequestBody EntBaseInfoDto entBaseInfoDto) {
        entService.delBaseEnt(entBaseInfoDto);
    }

    @ApiOperation("获取企业经营数据")
    @PostMapping("/base/get")
    @ResponseBody
    private EntBaseInfoDto getBaseEnt(@RequestParam(value = "id") Long id) {
        return entService.getBaseEnt(id);
    }

    @ApiOperation("分页查询企业经营数据")
    @PostMapping("/comm/page")
    @ResponseBody
    private PageDto<EntCommInfoDto> pageCommEnt(@RequestBody EntCommInfoDto entCommInfoDto,
                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        return entService.pageCommEnt(entCommInfoDto, pageSize, pageNum);
    }

    @ApiOperation("新增企业经营数据")
    @PostMapping("/comm/new")
    @ResponseBody
    private void newCommEnt(@RequestBody EntCommInfoDto entCommInfoDto) {
        entService.newCommEnt(entCommInfoDto);
    }

    @ApiOperation("更新企业经营数据")
    @PostMapping("/comm/update")
    @ResponseBody
    private void updateCommEnt(@RequestBody EntCommInfoDto entCommInfoDto) {
        entService.updateCommEnt(entCommInfoDto);
    }

    @ApiOperation("删除企业经营数据")
    @PostMapping("/comm/delete")
    @ResponseBody
    private void delCommEnt(@RequestBody EntCommInfoDto entCommInfoDto) {
        entService.delCommEnt(entCommInfoDto);
    }

    @ApiOperation("获取企业经营数据")
    @PostMapping("/comm/get")
    @ResponseBody
    private EntCommInfoDto getCommEnt(@RequestParam(value = "id") Long id) {
        return entService.getCommEnt(id);
    }
}
